(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
"use strict";

loader.define({
  depend: ['pages/config/config'],
  loaded: function loaded(config, require, exports, module, global) {
    this.pageview = {
      init: function init(e) {
        var height = $("#home2").height();
        var width = $("#home2").width();
        var set_width1 = width * 0.65.toString() + "px";
        var set_width2 = width * 0.25.toString() + "px";
        var loadcheck = ""; //回退界面

        $("#back_btn").click(function () {
          bui.back();
          bui.ajax({
            url: config.apiurl + "api/v1.0/mychange",
            data: {},
            method: "post",
            headers: {
              'Content-Type': 'application/json'
            }
          }).done(function (res) {
            $("#p1").text(res['staracts']);
          });
        }); //滑动页面布局加载

        var uiList = bui.list({
          id: "#scrollList2",
          url: config.apiurl + "api/v1.0/staract",
          pageSize: 100000,
          // 当pageSize 小于返回的数据大小的时候,则认为是最后一页,接口返回的数据最好能返回空数组,而不是null
          data: {},
          //如果分页的字段名不一样,通过field重新定义
          field: {
            page: "page",
            size: "pageSize",
            data: "activities"
          },
          callback: function callback(e) {//console.log("1:   "+e);
            // e.target 为你当前点击的元素
            // e.currentTarget 为你当前点击的handle 整行
          },
          template: function template(data) {
            var html = "";
            data.forEach(function (el, index) {
              console.log(el);
              var i = index % 4;
              var color = new Array();
              color = ["#F33C5A", "#FF59A7", "#6C3CF4", " #F3B53C"]; //console.log(color[i]);

              var panel = "<li class=\"bui-btn bui-box\" id=\"textcontainer\" style=\"background-color:".concat(color[i], "\">\n                                            <div class=\"activityname2\" style=\"text-align:left; padding-left:0.2rem; vertical-align:middle; overflow: hidden;  white-space: nowrap;text-overflow: ellipsis; width:").concat(set_width1, ";position: relative;bottom: 1px;right: 0px;\">\n                                                <h1 class=\"lop\" id=").concat(el.id, "+").concat(el.type, "+").concat(el.latitude, "+").concat(el.longitude, ">").concat(el.name, "</h1>\n                                            </div>\n                                            <div class=\"imagechoose2\" style=\"position: relative;bottom: 8px;right: 0px;width:").concat(set_width2, "\"padding-right:0.3rem;>\n                                                <img src=\"images/home/share.png\" class=\"imageshare\" id=").concat(el.id, ">\n                                                <img src=\"images/home/true.png\" class=\"imagechoose\" id=").concat(el.id, ">\n                                            </div>         \n                                        </li>");
              html += panel;
            }); //console.log("1:   "+data);

            return html;
          },
          onBeforeRefresh: function onBeforeRefresh() {
            console.log("brefore refresh");
          },
          onBeforeLoad: function onBeforeLoad() {
            console.log("brefore load");
          },
          onRefresh: function onRefresh() {
            // 刷新以后执行
            beginButton();
            console.log("refreshed");
          },
          onLoad: function onLoad() {
            // 刷新以后执行
            beginButton();
            console.log("loaded");
          }
        });

        function beginButton() {
          //查看detail
          $(".lop").on("click", function (e) {
            var id = $(this).attr('id');
            console.log(id);
            var list = id.trim().split("+"); //console.log(list);

            bui.load({
              url: "pages/activitydetail/activitydetail",
              param: {
                id: list[0],
                type: list[1],
                lat: list[2],
                lng: list[3]
              }
            });
          }, function (res, status) {
            console.log(status);
          }); //取消收藏按钮

          $(".imagechoose").on("click", function (e) {
            var id = $(this).attr('id');
            var name = $(this).attr('name');
            console.log(id);
            var idd = id.toString();
            var data_ = {
              "id": idd
            };
            data_ = JSON.stringify(data_);
            console.log(data_);
            var cancel = $(this);
            bui.confirm("确定要取消收藏吗", function (e) {
              //this 是指点击的按钮
              var text2 = $(e.target).text();

              if (text2 == "确定") {
                // 执行删除整行操作
                bui.ajax({
                  url: config.apiurl + "api/v1.0/delstaract",
                  method: "post",
                  data: data_,
                  headers: {
                    'Content-Type': 'application/json'
                  }
                }).done(function (res) {
                  console.log(res);
                  bui.ajax({
                    url: config.apiurl + "api/v1.0/mychange",
                    data: {},
                    method: "post",
                    headers: {
                      'Content-Type': 'application/json'
                    }
                  }).done(function (res) {
                    $("#p1").text(res['staracts']);
                  });
                }).fail(function (res, status) {
                  console.log(status); // status = "timeout" || "error" || "abort", "parsererror"
                });
                cancel.parents("li").fadeOut(300, function () {
                  cancel.remove();
                });
                bui.hint({
                  content: "<i class='icon-check'></i><br />取消成功",
                  position: "center",
                  effect: "fadeInDown"
                });
              }
            });
          }); //分享按钮
		
		$(".imageshare").on("click",
		function(e) {
		  var	targetId=$(this).attr("id");
     
      var t = bui.actionsheet({
        appendTo: "#home2",
        buttons: [{
          name: "微信好友分享",
          value: "session"
        },
        {
          name: "微信好友圈分享",
          value: "timeline"
        }],
        callback: function(e) {
          switch ($(e.target).attr("value")) {
          case "session":
            var t = {
              id: targetId
            };
            console.log(targetId);
            t = JSON.stringify(t),
            bui.ajax({
              url: config.apiurl + "api/v1.0/actdetails",
              data: t,
              method: "post",
              headers: {
                "Content-Type": "application/json"
              }
            }).then(function(e) {
              console.log(targetId);
              var t = Number(e.peoplecount),
              i = Number(e.peoplesurplus),
              o = String(t - i) + "/" + String(t);
              console.log(e.name, e.content, e.time, e.address, e.cost, o),
              shareHref2(targetId, e.name, e.content, e.time, e.address, e.cost, o, "session")
            },
            function(e, t) {
              console.log(t)
            }),
            this.hide();
            break;
          case "timeline":
            t = {
              id: targetId
            };
            t = JSON.stringify(t),
            bui.ajax({
              url: config.apiurl + "api/v1.0/actdetails",
              data: t,
              method: "post",
              headers: {
                "Content-Type": "application/json"
              }
            }).then(function(e) {
              var t = Number(e.peoplecount),
              i = Number(e.peoplesurplus),
              o = String(t - i) + "/" + String(t);
              console.log(e.name, e.content, e.time, e.address, e.cost, o),
              shareHref2(targetId, e.name, e.content, e.time, e.address, e.cost, o, "timeline")
            },
            function(e, t) {
              console.log(t)
            }),
            this.hide();
            break;
          case "cancel":
            this.hide()
          }
        }
      });
      t.show();
		},
		function(e, t) {
			console.log(t)
		})
        }

        return uiList;
      }
    };
    this.pageview.init();
    return this.pageview;
  }
});
},{}]},{},[1]);
